package com.bkgy.sys.common.entity;


import com.bkgy.sys.common.constant.CommonConstant;
import lombok.Data;

/**
 * 公众返回结果实体类(json的格式)
 *
 * @author cc
 */
@Data
public class ResultDataE<E> {

    private String msg; // 返回信息
    private Integer status; // 状态
    private E data;
    private Integer count; // 数据总数
    private Integer totle; // 总分(临时添加，可用可不用)

    public ResultDataE() {
    }

    public ResultDataE(String msg, Integer status, E data) {
        this.msg = msg;
        this.data = data;
        this.status = status;
        this.count = 0;
    }

    public ResultDataE(String msg, Integer status, E data, Integer count) {
        this.msg = msg;
        this.data = data;
        this.status = status;
        this.count = count;
    }
    /**
     * 分页查询对象
     *
     * @param data
     * @return
     */
    public ResultDataE<E> ResultDataSuccess(E data, Integer count) {
        return new ResultDataE<E>("访问数据接口成功", CommonConstant.success_status, data, count);
    }
    /**
     * 访问成功
     *
     * @param data
     * @return
     */
    public ResultDataE<E> ResultDataSuccess(E data) {
        return new ResultDataE<E>("访问数据接口成功", CommonConstant.success_status, data);
    }

    /**
     * 自定义访问成功
     *
     * @param msg
     * @param data
     * @return
     */
    public ResultDataE<E> ResultDataSuccessSelf(String msg, E data) {
        return new ResultDataE<E>(msg, CommonConstant.success_status, data);
    }

    /**
     * 访问失败自定义
     *
     * @param msg
     * @param data
     * @return
     */
    public ResultDataE<E> ResultDataFaultSelf(String msg, E data) {
        return new ResultDataE<E>(msg, CommonConstant.fault_status, data);
    }

    /**
     * 访问失败固定
     *
     * @param msg
     * @param data
     * @return
     */
    public ResultDataE<E> ResultDataFaultGd(String msg, E data) {
        return new ResultDataE<E>("访问数据失败，失败信息为" + msg, CommonConstant.fault_status, data);
    }

}
